Skip to content

test: stabilize flaky TestInstancePlanCacheConcurrencySysbench#69639

Open
flaky-claw wants to merge 1 commit into
pingcap:masterfrom
flaky-claw:flakyfixer/case_8c3b8c00dc15-a1
Open

test: stabilize flaky TestInstancePlanCacheConcurrencySysbench#69639
flaky-claw wants to merge 1 commit into
pingcap:masterfrom
flaky-claw:flakyfixer/case_8c3b8c00dc15-a1

Conversation

@flaky-claw

@flaky-claw flaky-claw commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #57514

Problem Summary:
Flaky test TestInstancePlanCacheConcurrencySysbench in pkg/planner/core/casetest/instanceplancache intermittently fails, so this PR stabilizes that path.

What changed and how does it work?

Root Cause

Unsynchronized multi-worker DML routing made lock deadlocks part of a plan-cache equivalence test.

Fix

Single-writer DML removes unrelated lock scheduling while preserving normal-vs-prepared SQL comparison under concurrent sessions.

Verification

Spec:

  • target: pkg/planner/core/casetest/instanceplancache :: TestInstancePlanCacheConcurrencySysbench
  • strategy: tidb.issue_scoped.v2
  • plan mode: BASELINE_ONLY
  • requirements: required case must execute; no skip; repeat count = 1
  • execution surface: GO_TEST_WITH_TAGS
  • build tags: intest, deadlock
  • baseline gates: required_flaky_gate, build_safety_gate, intent_guard_gate
  • feedback surface source: baseline_only

Observed result:

  • status: passed
  • required case executed: yes
  • submission decision: ALLOWED
  • note: Required flaky case executed during validation.
    Required flaky case was not skipped.
    target-flaky passed.
    package passed.
    build passed.
    lint passed.

Gate checklist:

  • pressure-repro: SKIPPED
  • target-flaky: PASS
  • package: PASS
  • build: PASS
  • lint: PASS

Commands:

  • go test -json -tags=intest,deadlock ./pkg/planner/core/casetest/instanceplancache -run '^TestInstancePlanCacheConcurrencySysbench$' -count=1
  • go test -json -tags=intest,deadlock ./pkg/planner/core/casetest/instanceplancache -count=1
  • make build
  • make lint

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Fixes #57514

Summary by CodeRabbit

  • Bug Fixes
    • Improved consistency in concurrent write testing so database changes stay within one session, reducing deadlock-related flakiness.
    • Simplified statement execution during DML handling to avoid skipping work after deadlocks, helping tests better reflect real behavior.

@ti-chi-bot ti-chi-bot Bot added release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 3, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign king-dylan for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: badf29e0-bc83-4f51-9912-4a283e2dd1c4

📥 Commits

Reviewing files that changed from the base of the PR and between 8be4bd0 and ab93b5d.

📒 Files selected for processing (1)
  • pkg/planner/core/casetest/instanceplancache/concurrency_test.go

📝 Walkthrough

Walkthrough

The concurrency test worker no longer tolerates deadlock errors during DML execution, and DML statements are now routed to a single randomly chosen worker session instead of being distributed randomly across sessions, to reduce deadlock occurrences and preserve session ordering.

Changes

Concurrency test deadlock fix

Layer / File(s) Summary
Serialize DML execution and routing
pkg/planner/core/casetest/instanceplancache/concurrency_test.go
Removes deadlock-specific error tolerance in worker.run (now always calls MustExec), and changes testWithWorkers to route all DML statements to one pre-selected worker session rather than randomly per statement.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested labels: approved, lgtm

Suggested reviewers: hawkingrei, tiancaiamao, Defined2014

Poem

One worker to write, one path to run,
No more dodging deadlocks under the sun,
A rabbit hops through tests once flaky,
Now steady, calm, and never shaky. 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: stabilizing the flaky TestInstancePlanCacheConcurrencySysbench test.
Description check ✅ Passed The description includes the issue link, problem summary, fix details, verification steps, and test checklist.
Linked Issues check ✅ Passed The PR addresses #57514 by removing deadlock-prone DML routing and stabilizing the exact flaky test.
Out of Scope Changes check ✅ Passed The changes stay scoped to the targeted concurrency test and its deadlock-prone execution path.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="Running error: context loading failed: failed to load packages: failed to load packages: failed to load with go/packages: context deadline exceeded"
level=error msg="Timeout exceeded: try increasing it by passing --timeout option"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.1115%. Comparing base (8be4bd0) to head (ab93b5d).

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #69639        +/-   ##
================================================
- Coverage   76.3268%   74.1115%   -2.2153%     
================================================
  Files          2041       2050         +9     
  Lines        560589     576524     +15935     
================================================
- Hits         427880     427271       -609     
- Misses       131808     149047     +17239     
+ Partials        901        206       -695     
Flag Coverage Δ
integration 40.7048% <ø> (+0.9995%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 60.4471% <ø> (ø)
parser ∅ <ø> (∅)
br 47.4650% <ø> (-15.2563%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flaky test TestInstancePlanCacheConcurrencySysbench

1 participant